package day04;

import work.JDBCUtils;
import work.MyDatasource1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class demo1 {
    public static void main(String[] args) {
        Connection conn=null;
        PreparedStatement prs=null;
        ResultSet rs=null;
        MyDatasource1 my=new MyDatasource1();
        try {
            conn = my.getConnection();
            prs=conn.prepareStatement("select * from gongsi");
            rs=prs.executeQuery();
            while (rs.next()){
                int a=rs.getInt("id");
                String b=rs.getString("name");
                String c= rs.getString("salary");
                System.out.println("工号："+a+"姓名："+b+"工资"+c);
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }finally {
            //JDBC的release
            JDBCUtils.release(conn,prs,rs);
        }


    }
}
